﻿/***
    Copyright 2012 Stijn Van Antwerpen

    This file is part of Qasparov.

    Qasparov is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Qasparov is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Qasparov. If not, see <http://www.gnu.org/licenses/>.

 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Com.Oxilly.Qsb.Core.SDK.Events;

namespace Com.Oxilly.Qsb.Core.Managers
{
    class LogManager : ManagerBase
    {
        public event EventHandler<LogEventArgs> OnLog;
  
        protected void FireOnLog(LogEventArgs e)
        {
            //TODO: Remove writing to EventLog
            EventLog.WriteEntry(e.Source, e.Message);
            //TODO: Fire Async
            if (OnLog != null) OnLog(this, e);
        }

        internal void Log(String msg, SourceLevels level = SourceLevels.Verbose)
        {
            FireOnLog(new LogEventArgs
              {
                  Level = level,
                  Message = msg,
                  Source = this.GetType().Name
              });
        }

        internal void Log(LogEventArgs log)
        {
            FireOnLog(log);
        }

        internal override void ReleaseResources()
        {
            
        }
    }
}
